﻿using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using G.Runtime;
using GameLibrary.Model;
using Microsoft.VisualBasic.PowerPacks;
using GameLibrary.Model.Core;

namespace GameDesigner.Source.Widgets
{
    public class MessagePanel
    {
        private readonly Game _Game;
        private readonly SimpleShape _Shape;
        
        private string _Message = "";
        
        public MessagePanel(Game pGame, SimpleShape pSimpleShape)
        {
            _Game = pGame;
            _Shape = pSimpleShape;
            
            pGame.Globals.MessageEvent += delegate(string message) 
            {
                _Message = message;
                _Shape.Refresh();
            };
        }
        
        public void Clear() 
        {
            _Message = "";
            _Shape.Refresh();
        }
        
        public void OnPaint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Font font = new Font("Comic Sans MS", 12);
            SolidBrush brush = new SolidBrush(Color.Black);
            Pen pen = new Pen(Color.LightGray, 1);
            e.Graphics.DrawString(_Message, font, brush, 
                  _Shape.Location.X, _Shape.Location.Y);
            pen.Dispose();
        }
        
    }
}
